package com.air.controller;

import com.air.domain.Blog;
import com.air.vo.query.BlogSearchCondition;
import com.air.service.BlogService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shent
 */
@RestController
@RequestMapping("blog")
//@CrossOrigin(origins = {"http://localhost:9528", "null"})
@Slf4j
@Api("博客管理")
public class BlogController {
    @Autowired
    BlogService blogService;

    @PostMapping("add")
    @ApiOperation("添加博客")
    public long addBlog(@RequestBody Blog blog) {
        return blogService.addBlog(blog);
    }

    @PostMapping("edit")
    public long editBlog(@RequestBody Blog blog) {
        return blogService.editBlog(blog);
    }

    @PostMapping("search")
    public IPage<Blog> searchBlog(@RequestBody BlogSearchCondition condition)  {
        return blogService.searchBlog(condition);
    }

    @PostMapping("test")
    public int test(@RequestBody Object object) {
        log.info(object.toString());
        return 1;
    }


}
